﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System.Runtime.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BrainTechLLC
{
    public delegate void ChangeDelegate(object o, PropertyData args, Signals signals);
    public delegate bool CheckDelegate(object o, SingleModification change, Signals signals);

    [Serializable]
    public class ModificationBaseClass : IChange
    {
        [DataMember]
        public ChangeDelegate ChangeToApply { get; set; }

        public virtual void ApplyChange(object o, Signals signals)
        {
            ChangeToApply(o, null, signals);
        }
    }

    [Serializable]
    [DataContract]
    public class SingleModification : ModificationBaseClass, IChange
    {
        [DataMember]
        public PropertyData Arguments { get; set; }

        public override void ApplyChange(object o, Signals signals)
        {
            ChangeToApply(o, Arguments, signals);
        }
    }

    [Serializable]
    [DataContract]
    public class PreOrPostRequisite
    {
        [DataMember]
        public CheckDelegate Check { get; set; }
    }

    [Serializable]
    [DataContract]
    public class Modification
    {
        [DataMember]
        public SingleModification Change { get; set; }
        [DataMember]
        public PreOrPostRequisite PrerequisiteForChange { get; set; }
        [DataMember]
        public PreOrPostRequisite PostChangeCheck { get; set; }
    }
}
